package com.activenetwork.util.verification;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.activenetwork.custom.uielement.decorate.IdentifierFactory;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.verification.gson.FailurePoint;

public class checkCalendarType implements VerificationAction {
	
	private static Logger logger = LoggerFactory.getLogger(checkCalendarType.class);
	private String pageName;
	private String pageField;
	private String caseName;
	private WebElement element;
	
	
	public checkCalendarType(String pageName, String pageField, String caseName){
		this.pageName = pageName;
		this.pageField = pageField;
		this.caseName = caseName;
		this.element = IdentifierFactory.createWebElement(pageName, pageField);
	}
	
	public checkCalendarType(WebElement element, String caseName){
		this.element = element;
		this.caseName = caseName;
	}

	@Override
	public void verify() {
		String dt = element.getAttribute("data-toggle").trim();
		if(!StringUtils.equalsIgnoreCase(dt, "datepicker")){
			logger.error(pageName + "-" + pageField + " expect:" + pageField + "is calendar type, " + " actual:" + pageField + " is not");
			EnvContext.failurePointTL.get().add(
					new FailurePoint(caseName, "Verify calendar Type", pageName + "-" + pageField + " expect:" + pageField + "is calendar type, " + " actual:" + pageField + " is not"));
		}
		
	}

}
